from sqlalchemy import (
    Column,
    Index,
    Integer,
    Text,
    Unicode,
    ForeignKey,
    Table,
    Float,
    DateTime
)

from sqlalchemy.orm import relationship

from .meta import Base

class Category(Base):
    __tablename__ = 'categories'
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(50), nullable=False, unique=True)
    parent_id = Column(Integer, ForeignKey('categories.id'),nullable=True)
    parent=relationship('Category',remote_side=[id],backref='children')

    def __unicode__(self):
        return self.name

    def __str__(self):
        return self.name